package com.senjoeson.manager.controller;


import com.senjoeson.manager.bean.Apkinfo;
import com.senjoeson.manager.result.ResultBean;
import com.senjoeson.manager.service.ApkInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * controller
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/apkinfo")
public class ApkInfoController {

    @Autowired
    private ApkInfoService mApkInfoService;


    @RequestMapping(value = "/findApkInfo",method = RequestMethod.GET)
    public ResultBean<?> getApkInfo(String appid) {
        if (appid == null || "".equals(appid)) {
            return new ResultBean<String>(500, "fail", "数据不能为空!");
        }
        Apkinfo singleApkInfo = mApkInfoService.getSingleApkInfo(appid);
        if (singleApkInfo == null) {
            return new ResultBean<String>(200, "success", "未查询到该appid对应的数据!");
        } else {
            return new ResultBean<>(singleApkInfo);
        }
    }


    @RequestMapping(value = "/getAllApkInfo")
    public ResultBean<List<Apkinfo>> getAllApkInfo(){
        List<Apkinfo> allApkInfo = mApkInfoService.getAllApkInfo();
        return new ResultBean<List<Apkinfo>>(200,"success",allApkInfo);
    }

}
